﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using compshop.Modules.Producers.Views;
using Microsoft.Practices.Prism.Events;
using compshop.Infrastructure;
using compshop.Infrastructure.CompShopDataService;

namespace compshop.Modules.Producers.Presenter
{
    public class ProducersPresenter
    {
        private readonly CompShopEntities contextDS;
        private IList<Producer> producers;
        private EventsManager eventsManager;

        public ProducersPresenter(EventsManager eventsManager)
        {
            contextDS = CompShopEntitiesContext.GetInstance();
            this.eventsManager = eventsManager;
            eventsManager.Presenter = this;
            eventsManager.Subscribe();

            producers = contextDS.Producers.Expand("GeneralProducts").ToList<Producer>();
        }

        public IViewProducer View { get; set; }

        public IList<Producer> ProducerList
        {
            get { return producers; }
            set { producers = value; }
        }

        #region Publishers

        public void ProducerSelectedPublisher(int id)
        {
            eventsManager.eventAggregator.GetEvent<ProducerSelectedEvent>().Publish(id);
        }

        #endregion

        #region Handlers

        #endregion

        

        

    }
}
